<!--
 * @description:
 * @fileName: EditPlayName
 * @author: 17076
 * @date: 2025/3/21-上午10:26
 * @version: V1.0.0
-->

<template>
  <cs-dialog
    :dialog="dialogOption"
    @onSubmit="save"
  >
    <div slot="content">
      <el-form ref="form" :model="infoForm" :rules="rules" label-width="100px">
        <el-form-item label="剧本名称" prop="playName">
          <el-input v-model="infoForm['playName']" placeholder="剧本名称" />
        </el-form-item>
      </el-form>
    </div>
  </cs-dialog>
</template>

<script>
import { updatePlayDescInfo } from '@/api/play'

export default {
  name: 'EditPlayName',
  data() {
    return {
      dialogOption: {
        width: '500px',
        title: {
          title: '重命名'
        },
        show: false
      },
      infoForm: {},
      rules: {
        playName: [{ required: true, trigger: 'blur', message: '剧本名称不能为空!' }]
      }
    }
  },
  methods: {
    // 显示弹窗
    show(data) {
      this.infoForm = this.$baseLodash.cloneDeep(data)
      this.dialogOption.show = true
    },
    save(callback) {
      this.$refs.form.validate(async(valid) => {
        if (valid) {
          const { code, msg } = await updatePlayDescInfo(this.infoForm)
          code === 200 ? this.$baseMessage.success(msg || '修改成功!') : this.$baseMessage.error(msg || '修改失败')
          this.$emit('reload-data')
          callback(true)
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
